include ../.env
export $(shell sed 's/=.*//' ../.env)

JDK_DOCKERFILE=./JDK-${JDK_VERSION}.Dockerfile
JDK_IMAGE_NAME=${IMAGE_REPO}/jdk-devel:${JDK_VERSION}

SCALA2_DOCKERFILE=./scala2.Dockerfile
SCALA2_IMAGE_NAME=${IMAGE_REPO}/scala:${SCALA2_VERSION}

SCALA3_DOCKERFILE=./scala3.Dockerfile
SCALA3_IMAGE_NAME=${IMAGE_REPO}/scala:${SCALA3_VERSION}

## using centos8

CENTOS_DOCKERFILE=./centos8.Dockerfile
CENTOS_IMAGE_NAME=${IMAGE_REPO}/centos:${CENTOS_VERSION}

MK_CENTOS=false

jdk-devel: 
ifeq (${MK_CENTOS},true)
	docker build -t ${CENTOS_IMAGE_NAME} --build-arg CENTOS_VERSION=${CENTOS_VERSION} -f ${CENTOS_DOCKERFILE} .
endif
	docker build -t ${JDK_IMAGE_NAME} \
	--build-arg CENTOS_VERSION=${CENTOS_VERSION}  \
	--build-arg IMAGE_REPO=${IMAGE_REPO}  \
	--build-arg JDK_VERSION=${JDK_VERSION} \
	-f ${JDK_DOCKERFILE} .

ifeq (${PUSH},true)
	docker push ${CENTOS_IMAGE_NAME}
	docker push ${JDK_IMAGE_NAME}
endif
.PHONY: scala2-devel
scala2-devel:
	docker build -t ${SCALA2_IMAGE_NAME} \
	--build-arg IMAGE_REPO=${IMAGE_REPO}  \
	--build-arg JDK_VERSION=${JDK_VERSION} \
	--build-arg SCALA2_VERSION=${SCALA2_VERSION} \
	-f ${SCALA2_DOCKERFILE} .

ifeq (${PUSH},true)
	docker push ${SCALA2_IMAGE_NAME}
endif

.PHONY: scala3-devel
scala3-devel:
	docker build -t ${SCALA3_IMAGE_NAME} \
	--build-arg IMAGE_REPO=${IMAGE_REPO}  \
	--build-arg JDK_VERSION=${JDK_VERSION} \
	--build-arg SCALA2_VERSION=${SCALA3_VERSION} \
	-f ${SCALA3_DOCKERFILE} .

ifeq (${PUSH},true)
	docker push ${SCALA3_IMAGE_NAME}
endif